#include <iostream>
using namespace std;

const int kMaxA = 1e6 + 10;

int f[kMaxA];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int ans = 0, n;

  for (cin >> n; n; n--) {
    int a, t;

    cin >> a;
    t = f[a] + 1;
    ans = max(ans, t);
    for (int x = a; x < kMaxA; x += a) {
      f[x] = max(f[x], t);
    }
  }
  cout << ans << "\n";
  return 0;
}